package android.explorer;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class CameraActivity extends Activity{
	private ImageView image;
	@Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cameraspace);
        
        Button back = (Button)findViewById(R.id.back);
        back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent homeIntent = new Intent(CameraActivity.this, Explorer.class);
				startActivity(homeIntent);
			}
		});
        
        Button loadCamera = (Button)findViewById(R.id.loadcamera);
        loadCamera.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent openCamara = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
				startActivityForResult(openCamara, 0);
			}
		});
	}
	
	 protected void onActivityResult(int requestCode, int resultCode, Intent intent){
		 super.onActivityResult(requestCode, resultCode, intent);
		 if(resultCode == RESULT_OK){			 
			 Bundle extras = intent.getExtras();
			 Bitmap bmp = (Bitmap) extras.get("data");
			 image = (ImageView)findViewById(R.id.cameraresult);
			 image.setImageBitmap(bmp);
		 }
		
	 }
}
